<template>
    <div class="waiting-queue-box">
        <div class="waiting-content-v">
            <commpVxeTable
            :isCanWrap="true"
            :config="dataTableConfig" 
            :columns="columnsVxe" 
            :formItem="formItem"
            ref="acceptanceRegistrationRef"
            :searchType="true"
            >
                <template v-slot:fsxmc_name="{row}" data-desc="自定操作栏">
                    <!-- <span v-if="row.fzwxtbzzt == '补正中'" class="fsxmcQ-c-t">[{{ row.fzwxtbzzt}}]</span>
                    <span v-if="row.fzwxtbzzt == '已补正'" class="fsxmcQ-l-t">[{{ row.fzwxtbzzt}}]</span>

                    <span v-if="row.fzwxtzgzt == '整改中'" class="fsxmcQ-c-t">[{{ row.fzwxtzgzt }}]</span>
                    <span v-if="row.fzwxtzgzt == '已整改'" class="fsxmcQ-l-t">[{{ row.fzwxtzgzt }}]</span>

                    <span v-if="row.fzwxtcjzt == '撤件回复'" class="fsxmcQ-h-t" @click="cjhfClick()">[{{ row.fzwxtcjzt }}]</span>
                    <span v-if="row.fzwxtcjzt == '撤件审核中'" class="fsxmcQ-c-t">[{{ row.fzwxtcjzt }}]</span>
                    <span v-if="row.fzwxtcjzt == '已撤件'" class="fsxmcQ-l-t">[{{ row.fzwxtcjzt }}]</span>

                    <span v-if="row.fzwxtthzt" class="fsxmcQ-h-t">{{ row.fzwxtthzt }}</span> -->
                    <a href="#" @click="viewingMattersClick(row)">{{ row.fsxmc }}</a>
                </template>
                <template v-slot:operation_btn="{row}">
                    <a-form layout="inline" class="search-form" >
                        <a-form-item >
                            <a-button class="blue-btn" type="primary" @click="advanceHandle(row)">提前办</a-button>
                        </a-form-item>
                    </a-form>
                </template>
            </commpVxeTable>
        </div>
        
        <taskAcceptanceIncrease ref="taskAcceptanceIncreaseRef" 
         :addEditParameter="addEditParameter" />
    </div>
</template>
<script>
import assessCheckApi from './service/api'
import commpVxeTable from '@/components/commp-vxe-table/commp-vxe-table.vue'
import blobType from '@/common/blobType'
import moment from 'moment'
import {spcyUpdateKbJobInBkb,spcyGetJobConcernByJobId} from './service/index'
import taskAcceptanceIncrease from '../allHandlingPage/manufacturing/taskAcceptance/increase.vue'
export default {
    components:{
        commpVxeTable,
        taskAcceptanceIncrease,
    },
    props:{

    },
    data(){
        return{
            // formItem:[{
            //     label: '事项名称',
            //     model: 'fsxmc',
            // },{
            //     label: '企业名称',
            //     model: 'fqymc',
            // },{
            //     label: '申请单号',
            //     model: 'fsqdbh',
            // },{
            //     label: '环节名称',
            //     model: 'fhjmc',
            //     placeholder: '环节名称',
            //     type:'Select',
            //     dictionaryType:'查验流程环节名称'
            // },{
            //     label: '发起人',
            //     model: 'ffsrmc',
            // },{
            //     label: '所属科室',
            //     model: 'fywflname',
            //     placeholder: '所属科室',
            //     type:'Select',
            //     dictionaryType:'科室业务分类'
            // },{
            //     label: '接收时间',
            //     model: ['slkssj','sljssj'],
            //     type:'rangePicker',
            //     format:'YYYY-MM-DD'
            // },{
            //     label: '流程状态',
            //     model: 'flczt',
            //     placeholder: '流程状态',
            //     type:'Select',
            //     dictionaryType:'审评查验流程状态'
            // }],
            formItem:[{
                label: '关键字',
                model: 'sxcxgjz',
                searchType:'展开',
            },{
                label: '事项名称',
                model: 'fsxmc',
                searchType:'收起',
            },{
                label: '申请单位名称',
                model: 'fqymc',
                searchType:'收起',
            },{
                label: '环节名称',
                model: 'fhjmc',
                placeholder: '环节名称',
                type:'Select',
                dictionaryType:'查验流程环节名称',
                searchType:'收起',
            },{
                label: '发送人',
                model: 'ffsrmc',
                searchType:'收起',
            },{
                label: '所属科室',
                model: 'fywflname',
                placeholder: '所属科室',
                type:'Select',
                dictionaryType:'科室业务分类',
                searchType:'收起',
            },{
                label: '接收时间',
                model: ['slkssj','sljssj'],
                type:'rangePicker',
                format:'YYYY-MM-DD',
                searchType:'收起',
            }],
            columnsVxe:[
            { 
                type: 'checkbox', 
                width: 60 ,
                fixed: 'left'
            },{
                title: '事项名称', //列头显示文字
                field: 'fsxmc',
                align:'left',
                slots: {
                    default: 'fsxmc_name',
                },
            },{
                title: '申请单位名称', //列头显示文字
                field: 'fqymc',
                align:'left',
            },{
                title: '任务编号',
                field: 'fslbh',
                width:90,
            },{
                title: '当前环节',
                field: 'fhjmc',
                width:90,
            },{
                title: '当前办理人',
                field: 'fdbr',
                width:90,
            },{
                title: '发起人',
                field: 'ffsrmc',
                width:90,
            },{
                title: '所属科室',
                field: 'fywflname',
            },
            // {
            //     title: '剩余天数',
            //     field: 'syday',
            //     width:75,
            // },
            {
                title: '接收时间',
                field: 'fslsj',
                slots: {
                    // 使用插槽模板渲染
                    default: 'name_fslsj',
                },
                width:90,
            },{
                title: '流程状态',
                field: 'flczt',
            }
            // ,{
            //     title: '操作',
            //     field: 'id',
            //     slots: {
            //         // 使用插槽模板渲染
            //         default: 'operation_btn',
            //     },
            //     fixed: 'right',
            //     width:75
            // }
            ],
            dataTableConfig:{
                api: assessCheckApi.list,
                rowId: 'jobid',
                fywflcode:blobType.fywflcodeArr[blobType.menuType.indexOf(this.$route.name.substring(this.$route.name.indexOf('__'),this.$route.name.indexOf('_a')+2))],
                paramet:{
                }
            },
            addEditParameter:{},
        }
    },
    watch:{

    },
    mounted(){
        
    },
    methods:{
        cjhfClick(){
            this.$route.push('/enterpriseWithdrawalApplication/index')
        },
        timeProcessing(val){
            if(val){
                val = val.slice(0,11)
            }
            return val
        },
        advanceHandle(val){
            //console.log(val)
            this.$refs.handlingOpinionsRef.getData({title:'提前办理',opinionType:'提前办理意见',isJudgeAfterClosing:false,valueData:{jobid:val.jobid}})
            this.$refs.handlingOpinionsRef.visible = true
        },
        getInputOpinion(val,row){
            this.$refs.handlingOpinionsRef.confirmLoadinghandle(true)
            spcyUpdateKbJobInBkb({fbz:val,jobid:row.jobid}).then(res=>{
                if(res.code == 200){
                    this.$message.success(res.message)
                    this.$refs.handlingOpinionsRef.visible = false
                    this.$refs.handlingOpinionsRef.confirmLoadinghandle(false)
                }else{
                    this.$message.warning(res.message)
                    this.$refs.handlingOpinionsRef.confirmLoadinghandle(false)
                }
            })
        },
        viewingMattersClick(row){
            //console.log(row)
            spcyGetJobConcernByJobId({jobid:row.jobid}).then(res=>{
                if(res.code == 200){
                    
                    //console.log(res)
                    let linkDetails = {...row,...res.result}
                    let data = linkDetails
                    let sqsx = linkDetails.sqsx
                    this.addEditParameter = {
                        ...row,
                        fywflcode:'001002',
                        ...this.linkDetails,
                        jobid:data.job.id,
                        fblzt:data.job.fblzt,
                        fthyj:data.job.fthyj,
                        ...sqsx,
                        sqsxid:sqsx.id,
                        fslzt:String(sqsx.fslzt),
                        fsqsj:sqsx.fsqsj?moment(sqsx.fsqsj).format('YYYY-MM-DD'):'',
                        fslsj:sqsx.fslsj?moment(sqsx.fslsj).format('YYYY-MM-DD'):'',
                        isOwn:true,
                        dbrid:[],
                        opinion:'',//办理意见
                        smgflag:false,//是否发送短信
                        ...data.qy,
                        isReadOnly:true,
                        isOwn:false,
                        isHandle:true,
                        isTabs:true,
                        isMaterialSummary:true,
                    }
                    this.$refs.taskAcceptanceIncreaseRef.visibleShow = true
                    this.$refs.taskAcceptanceIncreaseRef.spinning = true
                    this.$refs.taskAcceptanceIncreaseRef.getData(this.addEditParameter)
                }else{
                    this.$message.warning(res.message)
                }
            })
        },
    }
}
</script>
<style lang="less">
.waiting-queue-box{
    background: #fff;
    .waiting-content-v{
        height: calc(100vh - 191px -48px);
    }
}
</style>